package com.yunwaikeji.gy_tool_library.adapter;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.yunwaikeji.gy_tool_library.R;
import com.yunwaikeji.gy_tool_library.adapter.recycler.GYRecyclerAdapter;
import com.yunwaikeji.gy_tool_library.adapter.recycler.GYViewHolder;

import java.util.ArrayList;
import java.util.List;

public class GYFragmentAdapter extends GYRecyclerAdapter<Fragment, GYViewHolder> {

    private FragmentManager fragmentManager;

    public GYFragmentAdapter(FragmentManager fragmentManager) {
        this(fragmentManager, new ArrayList<>());
    }

    public GYFragmentAdapter(FragmentManager fragmentManager, @Nullable List<Fragment> data) {
        super(R.layout.adapter_gy_fragment, data);
        this.fragmentManager = fragmentManager;
    }

    @Override
    protected void convert(GYViewHolder holder, Fragment fragment) {
        fragmentManager.beginTransaction().replace(R.id.fragmentLayout, fragment);
    }
}
